<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>实现双向绑定</title>
		<script src="../../vue/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
			<c10 :number1='num1':number2='num2' @num1Input='num1change' @num2Input='num2change' ></c10>
		</div>
		<template id="cp">
			<div id="">
				<h2>props:{{number1}}</h2>
				<h2>data:{{dnumber1}}</h2>
			
				<!-- <input type="text" v-model="dnumber1" /> -->
				<input type="text"  :value="number1" @input="num1Input" />
				<h2>props:{{number2}}</h2>
				<h2>data:{{dnumber2}}</h2>
				<input type="text"  :value="number2" @input="num2Input" />
				<input type="text" v-model="dnumber2" />
			</div>
		</template>
		<script type="text/javascript">
			
			var spp = new Vue({
				el:'#app',
				data:{
					num1:0,
					num2:1
				},
				methods:{
					num1change(value){
						this.num1 = value;
					},
					num2change(value){
						this.num2= value;
					}
				},
				components:{
					c10:{
						template:'#cp',
						props:{
							number1:Number,
							number2:Number
						}
					},
					data(){
						return{
							dnumber1:this.number1,
							dnumber2:this.number2，,
							
						}
					},
					methods:{
						num1Input(event){
							this.number1 = event.target.value;
							this.$emit('num1change',this.number1);
						},
						num2Input(event){
							this.number2 = event.target.value;
							this.$emit('num2change',this.number2);
						}
					}
				}
			});
		</script>
	</body>
</html>
